// att.h: interHedFace for the attribute classes.
//
//////////////////////////////////////////////////////////////////////


#ifndef ATT_H
#define ATT_H

#include <stdio.h>


// Attribute type
//////////////////////////////////////////////////////////////////////
enum
{
  CURVE_UNIFORM_FORCE = 0,
  CURVE_LINEAR_FORCE,
  CURVE_SUPPORT,
  NODAL_FORCE,
  NODAL_SUPPORT,
  FACE_PROPER
};

//////////////////////////////////////////////////////////////////////////
class acmF_Attribute;
class multiRectangle;
class drawGRA;

// Attribute structures
//////////////////////////////////////////////////////////////////////////
class VertAtt
{
public:
  VertAtt () {obj_att = NULL;};
  virtual ~VertAtt () {if (obj_att != NULL) delete obj_att;};

  int      select;
  int      id;
  acmF_Attribute *obj_att;
} ;


//////////////////////////////////////////////////////////////////////////
class EdgeSub
{
public:
  EdgeSub () {num_sub = 1; ratio = 1.0; size = 0.0; npts = 0; pts = NULL;};

  int      num_sub;
  double   ratio;
  double   size;

  int     npts;
  double *pts;
};


//////////////////////////////////////////////////////////////////////////
class EdgeAtt
{
public:
  EdgeAtt () {select = 0; id = 0; obj_att = NULL;};
  virtual ~EdgeAtt () {if (obj_att != NULL) delete obj_att;};

  int      select;
  int      id;
  EdgeSub  Subdivision;

  acmF_Attribute *obj_att;
  acmF_Attribute *mat_attr;

  multiRectangle *section;
} ;


//
// -----------------------------------------------------------------------------
// 		Curve Attributes Type Definitions:
//

// acmF_Attribute
//////////////////////////////////////////////////////////////////////
class acmF_Attribute
{

public:

  char    AttName[256];

  int     id;

  static  acmF_Attribute *CreateAttribute (int type);
  static  acmF_Attribute *CreateAttribute (char *type);

  virtual void           Read        (FILE *fp) = 0;
  virtual void           Save        (FILE *fp) = 0;

  virtual void           SetParam    (double *param) = 0;
  virtual void           GetParam    (int *np, double **param) = 0;
  virtual int            GetNumParam (void) = 0;
  virtual acmF_Attribute *Copy       (void) = 0;
 
  virtual void           Draw (int n, double *par) {};

  // set the methods to draw the curve
  void      setDraw( drawGRA *_obj ) { m_pDrawObj = _obj; }
  drawGRA * getDraw( ) {return m_pDrawObj; }

protected:
  drawGRA*   m_pDrawObj;  // object used to draw

  // draw support methods
  //	1 : restrained in only one dir.
  //  2 : simply supported
  //  3 : fixed
  void drawSupport1 ( double *pts, double size, double angle);
  void drawSupport2 ( double *pts, double size, double angle );
  void drawSupport3 ( double *pts, double size, double angle );

  void rotatePoints ( double ang, double *p, double *pts, int npts);
  void matrixMultVector (int MA, int NA, int MB, double	A[3][3],
                         double	B[3], double	AB[3]);

  
};



// acmF_CurveForce
//////////////////////////////////////////////////////////////////////
class acmF_CurveForce : public acmF_Attribute
{
public:
  double	   qx,qy,qz;
  double	   mx,my,mz;
  int        system;            /* 0 - global  1 - local */

             acmF_CurveForce  (void);
  virtual    ~acmF_CurveForce (void);

  void       Read (FILE *fp);
  void       Save (FILE *fp);
  void       SetParam    (double *param);
  void       GetParam    (int *np, double **param);
  int        GetNumParam (void) {return 7;};
  acmF_Attribute *Copy   (void);
};



// acmF_CurveSupport
//////////////////////////////////////////////////////////////////////
class acmF_CurveSupport : public acmF_Attribute
{
public:
  int			   sup[6];

             acmF_CurveSupport  (void);
  virtual    ~acmF_CurveSupport (void);

  void       Read (FILE *fp);
  void       Save (FILE *fp);
  void       SetParam    (double *param);
  void       GetParam    (int *np, double **param);
  int        GetNumParam (void) {return 6;};
  acmF_Attribute *Copy   (void);

  void       Draw (int n, double *par);
};


// acmF_NodalForce
//////////////////////////////////////////////////////////////////////
class acmF_NodalForce : public acmF_Attribute
{
public:
  double     fx,fy,fz;
  double     mx,my,mz;

             acmF_NodalForce  (void);
  virtual    ~acmF_NodalForce (void);

  void       Read (FILE *fp);
  void       Save (FILE *fp);
  void       SetParam    (double *param);
  void       GetParam    (int *np, double **param);
  int        GetNumParam (void) {return 8;};
  acmF_Attribute *Copy   (void);
};

#if 0
// acmF_NodalSupport
//////////////////////////////////////////////////////////////////////
class acmF_NodalSupport : public acmF_Attribute
{
public:
  int        sup[6];

             acmF_NodalSupport  (void);
  virtual    ~acmF_NodalSupport (void);

  void       Read (FILE *fp);
  void       Save (FILE *fp);
  void       SetParam    (double *param);
  void       GetParam    (int *np, double **param);
  int        GetNumParam (void) {return 8;};
  acmF_Attribute *Copy   (void);
};

#endif




// acmF_FaceProper
//////////////////////////////////////////////////////////////////////
class acmF_MatLinProper : public acmF_Attribute
{
public:

  // parameters
  double     E;          // Young Modulo
  double     nu;         // Poison

             acmF_MatLinProper  (void);
  virtual    ~acmF_MatLinProper (void);

  void       Read (FILE *fp);
  void       Save (FILE *fp);
  void       SetParam    (double *param);
  void       GetParam    (int *np, double **param);
  int        GetNumParam (void) {return 2;};
  acmF_Attribute *Copy   (void);
};

#endif

